/*
 * @Author: Zeratul
 * @Date: 2020-08-24 02:31:35
 * @LastEditTime: 2020-08-24 14:57:40
 * @FilePath: \sz-h5-2003-react-mobile\zhangminhui\eleme-react\eleme-user\src\store\reducer\loginReducer\index.js
 */
import {
  CHANGEUSERNAME,
  CHANGEINPUTTEL2,
  CHANGEINPUTMA,
  CHANGEINPUTPASSWORD2,
  REGIST_200,
  CODE_200,
} from "../../actionType";
const defaultState = {
  inpNamePH: "手机号",
  inputPasswordPH: "密码",
  register: "注册",
  forgetPwd: "忘记密码",
  isRegist: false,
  userInfo: {},
  code: "",
  userName: "",
  telephone: "",
  ma: "",
  password: "",
  code1: "",
};
export default function (state = defaultState, action) {
  let newState = JSON.parse(JSON.stringify(state));
  switch (action.type) {
    case CHANGEUSERNAME:
      newState.userName = action.params;
      break;
    case CHANGEINPUTTEL2:
      newState.telephone = action.params;
      break;
    case CHANGEINPUTMA:
      newState.ma = action.params;
      break;
    case CHANGEINPUTPASSWORD2:
      newState.password = action.params;
      break;
    case REGIST_200:
      newState.isRegist = true;
      for (let key in action.userInfo) {
        newState.userInfo[key] = action.userInfo[key];
      }
      break;
    case CODE_200:
      newState.code1 = action.code1;
      break;
    default:
      break;
  }
  return newState;
}
